/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 *
 * ***************************************************************************/

using System;
using System.Collections.Generic;
using Microsoft.Scripting.Utils;

namespace Microsoft.Scripting.Runtime {
    /// <summary>
    /// An attribute that is applied to saved ScriptCode's to be used to re-create the ScriptCode
    /// from disk.
    /// </summary>
    [AttributeUsage(AttributeTargets.Method)]
    public sealed class DlrCachedCodeAttribute : Attribute {
        private readonly Type/*!*/ _lcType;
        private readonly string[] _names;

        // TODO: remove
        public DlrCachedCodeAttribute() {
        }

        public DlrCachedCodeAttribute(Type/*!*/ languageContextType, string[] names) {
            ContractUtils.RequiresNotNull(languageContextType, "languageContextType");
            _lcType = languageContextType;
            _names = names;
        }

        public Type/*!*/ LanguageContextType {
            get {
                return _lcType;
            }
        }

        // TODO: use in ScriptCode instead of code[0].Names != null
        //internal bool HasOptimizedScope {
        //    get {
        //        return _names != null;
        //    }
        //}

        /// <summary>
        /// Gets names stored in optimized scope. Returns null if the code wasn't compiled with an optimized scope.
        /// </summary>
        public IList<String> Names {
            get {
                return _names;
            }
        }
    }
}
